<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<div id="d1" style="display:none;">
    <textarea id="t"></textarea><br/>

</div>
<button onclick="save()">保存</button>

<button onclick="javascript:d1.style.display='block';t.focus();">发表</button>

<div id="d2">

</div>

<script>
    //值得玩味
    var newTieZi;

    function save(){
        var newdiv = document.createElement("div");
        newdiv.innerHTML = t.value;

        if(newTieZi){
            d2.insertBefore(newdiv,newTieZi);
        }else{
            d2.appendChild(newdiv);
        }

        newTieZi = newdiv;

        d1.style.display = "none";
        t.value = "";
    }
</script>
</body>
</html>